<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" isELIgnored="false" import="java.util.*"
	pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>渠道运价分析——恒拓运价魔方</title>
<%-- <%@ include file="/common/liger_ui.jsp" %> --%>

<%-- <script type="text/javascript" src="<%=request.getContextPath() %>/fare/js/show.js"></script> --%>
<script type="text/javascript"
	src="<%=request.getContextPath() %>/fare/js/jquery-1.6.4.min.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath() %>/fare/js/datePicker/WdatePicker.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath() %>/FusionCharts/FusionCharts.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath() %>/fare/lib/ligerUI/js/ligerui.min.js"></script>
<link
	href="<%=request.getContextPath() %>/fare/lib/ligerUI/skins/Aqua/css/ligerui-all.css"
	rel="stylesheet" type="text/css" />
<link href="<%=request.getContextPath() %>/fare/css/base.css"
	rel="stylesheet" type="text/css" />
<script type="text/javascript"
	src="<%=request.getContextPath() %>/jsFile/common.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath() %>/jsFile/multiblepicker.js"></script>
<script src="<%=request.getContextPath() %>/fare/js/loadPlaneNo.js" type="text/javascript"></script>

<%-- <link
	href='<%=request.getContextPath() %>/fare/js/cityquery/cityquery.css'
	rel="stylesheet" type="text/css" />
<script type='text/javascript'
	src='<%=request.getContextPath() %>/fare/js/cityquery/citylist.js'></script>
<script type='text/javascript'
	src='<%=request.getContextPath() %>/fare/js/cityquery/querycity.js'></script>
 --%>
<link rev="stylesheet" media="all"
	href="<%=request.getContextPath() %>/fare/css/form_style.css"
	type="text/css" rel="stylesheet">
	
<script type="text/javascript"
	src="<%=request.getContextPath() %>/jsFile/wait/js/wait.js"></script>	
<!-- 圆角文本框 -->
<link href="<%=request.getContextPath() %>/fare/css/htc/htc.css" rel="stylesheet" type="text/css" />
	<script>

var columns_main = [
               { display: '序号', name: 'rowId', width: 80, render: function(data, index) { return (this.options.page-1)*this.options.pageSize+index+1;} },
               { display: '代理商', name: 'agentName', width: 200},
               { display: '网站', name: 'siteName', width: 170 },
               { display: '网站价格', name: 'sitePrice', width: 170 },
               { display: '官网价格', name: 'offiPrice', width: 190 },
               { display: '价差比例', name: 'priceDiffRatio', width: 180 }
               ];

function showm(sid){

var which = document.getElementById("lite" + sid);
var imgmenu = document.getElementById("ling" + sid);
	if (which.style.display == "none"){
		document.getElementById("lite" + sid).style.display="";
	}
	else{
		document.getElementById("lite" + sid).style.display="none";
		}

}

function changeP(pos){
	
	$('#table1').datagrid({pagePosition:pos});
	$('#table1').datagrid('loadData',json);
	$('#table1').datagrid({pagePosition:pos});
}

function currentDate(){ 
    var now = new Date();       
    var year = now.getFullYear();
    var month = now.getMonth() + 1;
    var day = now.getDate();
   
    var today = year + "-";       
    if(month < 10)
        today += "0";       
    today += month + "-";       
    if(day < 10)
        today += "0";           
    today += day;       
    return(today); 
}






function setTimeFunction(){
	 var objS = document.getElementById("flightNo"); 
    var grade = objS.options[objS.selectedIndex].grade;
    
    if($("#flightNo").val()==""||$("#flightNo").val()==null) {
		 $("#flightTime").html("");
	 }
    $("#flightTime").html(grade);
    $("#Times").attr("value",grade);
    $("#flightNos").attr("value",$("#flightNo").val());
    
   // $("#flightTime").html(grade);
}

//加载页面时进行初始化操作
$(function(){
	var grid = $("#maingrid");
	//loadAndDisplayData(grid,'channelsPriceAnalysisAction!analyse.action');
	grid.ligerGrid({
		width:988,
        height:300,
		pageSize:20,
        enabledSort:false,    // 就否允许排序
        columns:columns_main,
		resizable:false
    });
/* 
	$('#depCity').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList});
	$('#arrCity').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList}); */
	$('#depCity').querycity({'data':citysFlight,'tabs':labelFromcity});
	$('#arrCity').querycity({'data':citysFlight,'tabs':labelFromcity});
	var dataGridColumns = [{ header: '航空公司名', name: 'name' }];
	registSimplePicker2('carriers',"pageUtilAction!carriers.action",dataGridColumns,300,400,'name');

	//$('#airLineCompany').val('中国南方航空公司');
	if($('#channel').val()==''){
		$('#channel').val('去哪儿网');
	}
	
    if($('#grapDate').val()==''){
		$('#grapDate').val(currentDate());
	}
	if($('#flightDate').val()==''){
		$('#flightDate').val(currentDate());
	} 
	if($('#preRanking').val()==''){
		$('#preRanking').val('10');
	}
});

function loadAndDisplayData(grid,url){
	var preRanking;
	if($("input[name='rankingType']:checked").val()=='1'){
		preRanking = $('#preRanking').val();
	}else if($("input[name='rankingType']:checked").val()=='2'){
		
		preRanking = $("#chooseAll").val();
	}
	
	
	if($('#depCity').val()!=''&& $('#arrCity').val()!=''){
		var hour = $("#flightTime").html().split(":")[0];
		var channels = '';
		if($('#channel').val() == 'all'){
			$("#channel option").each(function() {  
				
		        if ($(this).val() != 'all') {  
		                channels = channels+ ','+ $(this).val();
		            } 
		        });
			//去掉逗号
			channels = channels.substring(1,channels.length);
		}else{
			channels = $('#channel').val();
		}
		
		$.ajax({
	        url : url,
	        data:{
	        	fromCity:$('#depCity').val(),
	        	toCity:$('#arrCity').val(),
	        	channel:channels,   
	        	grapDate:$('#grapDate').val(),
	        	bookingType:$('#bookingType').val(),
	        	airLineCompany:$('#airLineCompany').val(),
	        	flightNo:$('#flightNo').val(),
	        	flightDate:$('#flightDate').val(),
	        	preRanking:preRanking,
	        	flightTime:hour,
	        	agentName:$("#agentName").val()
	        	},
	        cache : false, 
	        async : true,
	        type : "POST",
	        beforeSend:function(){
	        	FDCWait.show();
	        },
	       	complete: function(jqXHR, textStatus){
	       		if(jqXHR.status==200){
	       			result = parseObj(jqXHR.responseText);
	       			var data = result.json;
	       			var XML = result.XML;
	       			if(data.Total != 0){
		        	grid.ligerGrid({
		                height:'300px',
		                columns:columns_main,
		                enabledSort:false,    // 就否允许排序
		                data:data,
		                resizable:false
		            });
		        	
		        	$('#area_chart').show();
		        	$('#container').show();
		        	$('#text').val(XML);
		        	setChart();
	       			
		       		}else{
		       			alert("该航班没有相应的数据,请重新选择!");
		       		}
	       		}
	       		else{
	       			alert('查询失败,请与管理员联系');
	       		}
	       		FDCWait.hide();
	       	}
	    });
	}
	
}


function checkiForm(){
	//以下是一些验证代码
	if($('#depCity').val()=='请选择' || $('#arrCity').val()=='请选择'){
		alert('请填写航线!');
	    return false;
	}
    
	if($('#depCity').val()== $('#arrCity').val()){
		alert('出发地与目的地不能一样!');
	    return false;
	}
	
	if($('#airLineCompany').val()==''){
		alert('航空公司必须填写!');
		return false;
	}
	if($('#flightNo').val()==''){
		alert('请先选择航班!');
		return false;
	}

	if($('#flightDate').val()==''||$('#flightDate').val()=='请选择'){
		alert('请填写航班日期!');
		return false;
	}

	if($('#grapDate').val()==''){
		alert('请填写抓取日期!');
		return false;
	}
	if(!checkTime()){
		return false;
	}
	
	if($('input[name="rankingType"]:checked').val()=='1'){
		if($('#preRanking').val()==''){
			alert("请指定最大排名数!");
			return false;
		}
	} 
	
	return true;
}

//以下是时间的验证
function checkTime(){
	var startTime = $("#flightDate").val();  
    var start = new Date(startTime.replace("-", "/").replace("-", "/"));  
    var endTime = $("#grapDate").val();  
    var end = new Date(endTime.replace("-", "/").replace("-", "/")); 
    var time = start.getTime()-end.getTime();//获得毫秒数差
    if(time<0){
    	alert('航班日期需要比抓取时间晚些!');
        return false;
    }
    //var days = Math.floor(time/(24*3600*1000));//计算相差日期
 	if(time>30*24*60*60*1000){
   		alert('航班日期与抓取时间差最多为30天!');
        return false; 
   	}
	return true;
}

function checkJspForm(){
	if(!checkiForm()){
		return false;
	}
	
	setTimeout(function(){loadAndDisplayData($('#maingrid'),'channelsPriceAnalysisAction!analyse.action');},1);
}
function resetForm(){
	$("#depCity").val("请选择");
	$("#arrCity").val("请选择");
	$('#agentName').val('');
	$('#flightDate').val(currentDate());

	
	var objSelect=document.getElementById("flightNo");
    objSelect.length=0;
    var varItem = new Option("--请选择--", "");      
    objSelect.options.add(varItem);    
    
	v1=v2=v3=null;
    
	$('#channel').attr("value",'all');
	$('#grapDate').val(currentDate());
	$("#flightTime").html('');
	$('#preRanking').val('10');
	$("#rankingType").attr("checked",'checked');
}

</script>
	<style type="text/css">
<!--
.STYLE1 {
	color: #990000;
	font-weight: bold;
}
-->
</style>
</head>

<body>

	<jsp:include page="../../inc/treelist3.jsp"></jsp:include>
	<jsp:include page="/pages/system/feedback/feedback.jsp" ></jsp:include>
	<div class="main main_max">
		<div class="sideBar">
			<div class="box">
				<div class="location">当前位置： 渠道分析 &gt; 渠道运价分析</div>
			</div>
		</div>
		<div class="content">
			<form id="iform" method="post">
				<div class="form_table_tltle">渠道运价分析</div>
				<input type="hidden" name="grabChannel2H" value="${grabChannel2}" id="grabChannel2H"> 
				<input type="hidden" value="${grabChannel2 }" id="hgrabChannel2" name="hgrabChannel2" />
					<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0 class="form_table">
						<TR>
							<TD width="10%" height="26" class="left" style="text-align: left">航空公司：</TD>
							<TD width="40%">
							<select class="easyui-combobox" name="airLineCompany" style="width: 150px;" id="airLineCompany" disabled="disabled">
								<c:forEach var="item" items="${crawlCompanys}">
									<option value="${item.hbaseKey}"
									<c:if test="${item.hbaseKey==sessionScope.currentUser.sourceId}">selected='selected' </c:if>
									>${item.name}</option>
								</c:forEach>	
							</select> <span style="color: #ff0000">*</span></TD>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
						</TR>
						<TR>
							<TD width="10%" height="26" class="left" style="text-align: left">航&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;线：</TD>
							<TD width="40%">
							<jsp:include page="/inc/flightSelect.jsp"></jsp:include>
						     	  <%--  <span></span> 
							<input type="text" name="depCity" style="width: 100px" id="depCity" value="请选择" readonly="readonly">
							       <span>到</span> 
							 <input type="text" name="arrCity" style="width: 100px" id="arrCity" value="请选择" readonly="readonly"> 
									<span style="color: #ff0000">*</span> --%>
							</TD>
							<TD width="10%" height="26" class="left" style="text-align: left">航&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;班：</TD>
							<td>
							<select name="vo.flightNo" id="flightNo" onclick="loadFlightNo()" onchange="setTimeFunction()">
									
									<c:if test="${not empty vo.flightNo }">
										<option id="flightNo2" value="${vo.flightNo }">${vo.flightNo }</option>
									</c:if>
									<c:if test="${empty vo.flightNo }">
										<option value="">--请选择--</option>
									</c:if>
							</select><font color="red">*</font>
							 <span id="flightTime">
							 <input id="Times" name= "vo.flightTimes"  type="hidden"  value="${vo.flightTimes }" /></span>
							</td>
							</TD>
						</TR>
						<TR>
							<TD width="10%" height="26" class="left" style="text-align: left">航班日期：</TD>
							<TD width="40%"><input type="text" name="flightDate" style="width: 100px" id="flightDate" value="${flightDate }" onClick="WdatePicker({skin:'whyGreen',lang:'<s:text name='forms.locale'/>'})" readonly="readonly">
											<span style="color: #ff0000">*</span></TD>
							<TD width="10%" height="26" class="left" style="text-align: left">抓取日期：</TD>
							<TD width="40%"><input type="text" name="grapDate" style="width: 100px" id="grapDate" value="${grapDate }" onClick="WdatePicker({skin:'whyGreen',lang:'<s:text name='forms.locale'/>',maxDate: '%y-%M-%d'})" readonly="readonly">
											<span style="color: #ff0000">*</span></TD>
						</TR>


						<TR>
							<TD width="10%" height="26" class="left" style="text-align: left">网&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;站：</TD>
							<TD width="40%">
							<select class="easyui-combobox"
								name="channel" style="width: 100px;" id="channel">
									<option value="all" selected="selected">全网</option>
									<c:forEach var="item" items="${crawlChannels}">
										<option value="${item.hbaseKey}">${item.name}</option>
									</c:forEach>
							</select>
							</TD>
							<TD width="10%" height="26" class="left" style="text-align: left">代&nbsp;&nbsp;理&nbsp;&nbsp;商：</TD>
							<TD width="40%"><input id="agentName" name="agentName"
								style="width: 100px" id="text7" value="${agentName }"></TD>
						</TR>


						<TR>
							<TD width="10%" height="26" class="left" style="text-align: left">排&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：</TD>
							<TD colspan="3">
								<input id="rankingType" name="rankingType" value="1" type="radio" checked="checked">前&nbsp; 
								<input type="text" style="width: 30px" maxlength="2" name="preRanking" id="preRanking" value="${preRanking }" 
								        onkeyup="this.value=this.value.replace(/\D/g,'')"
										onafterpaste="this.value=this.value.replace(/\D/g,'')">&nbsp;名&nbsp;
											&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<input id="rankingType" name="rankingType" value="2" type="radio">全&nbsp;部&nbsp;
								<input type="text" id="chooseAll" value="all" style="display: none;">
							</TD>
						</TR>

						<TR>
							<TD style="text-align: center; height: 35px;" colspan="4">
								<input type="button" class="btn01" value="" onclick="javascript:checkJspForm();" id="Submit2" /> 
								<input type="button" name="Submit222" class="btn02" value=""onclick="javascript:resetForm();" id="Submit222" />
							</TD>
						</TR>
					</TABLE>
			</form>
			<p></p>
			<br>

					

				<div id="area_chart" style="margin-top: 17px; font-size: 16px; padding: 0px 0px 0px 0px; width: 1000px; float: left; display: none">
				<div id="container"style="min-width: 400px; height: 360px; margin: 0 auto; float: left; display: none"></div>
                <div style="display: none">
						<input id="text" type="text" value="" />">
				</div>
				<script language="JavaScript">
				  function setChart(){
						$("#chartContainer").show();
					 	var xml = document.getElementById('text').value;
					 	var width = '990';
					 	var dateDiffs = parseInt($("#endDateAfterToday").val())*1 - parseInt($("#beginDateAfterToday").val())*1;
					 	if(dateDiffs*1>15){
					 		width = (750*1 + (dateDiffs*1-15)*50)+'';
					 		$('#area_chart').css('width','990px');
					 	}
						var chart2 = new FusionCharts("<%=request.getContextPath() %>/FusionCharts/Scatter.swf",
													"chart2Id", width, "350");
											chart2.setDataXML(xml);
											chart2.render("container");
										}
				</script>
			</div>
				<div id="maingrid" style="margin-top: 5px; float: left"></div>
		</div>
	</div>
	<br><br><br><br><br><br><br><br><br><br><br><br>
	<jsp:include page="../../inc/footer2.jsp"></jsp:include>

</body>

</html>
<style>
<!--
.l-grid-hd-cell-text{
text-align: center;
cursor:text;
}
-->
</style>

